package com.tools.common.util;

public class Constant {
    /**
    *文件上传路径
    * */
    public static final String UPLOAD_PATH="/var/file/static";

    public enum FilePath {
        AAC(10001,".acc","/audio/acc","AAC音频"),

        MP3(10002,".mp3","/audio/mp3","MP3音频"),

        WAV(10003,".wav","/audio/wav","波形音频格式"),

        AVI(20004,".avi","/video/avi","音频视频交错格式"),

        MP4(20005,".mp4","/video/mp4","MP4视频"),

        GIF(30001,".gif","/image/gif","图形交换格式（GIF）"),

        JPEG(30002,".jpeg","/image/jpeg","JPEG图像"),

        JPG(30003,".jpg","/image/jpg","JPG图像"),

        PNG(30004,".png","/image/png","便携式网络图形");
        private int index;
        private String suffix;
        private String path;
        private String describe;

        FilePath(int index, String suffix, String path, String describe) {
            this.index = index;
            this.suffix = suffix;
            this.path = path;
            this.describe = describe;
        }

        public int getIndex() {
            return index;
        }

        public String getSuffix() {
            return suffix;
        }

        public String getPath() {
            return path;
        }

        public String getDescribe() {
            return describe;
        }

        /**
         * 通过文件后缀获取文件上传路径
        * */
        public static String getUploadPath(String suffix) {
            FilePath[] filePath=values();
            for (FilePath f : filePath) {
                if (f.getSuffix().equals(suffix)){
                    return f.getPath();
                }
            }
            return null;
        }
        /**
         * 通过文件后缀获取文件上传路径
        * */
        public static int getUploadIndex(String suffix) {
            FilePath[] filePath=values();
            for (FilePath f : filePath) {
                if (f.getSuffix().equals(suffix)){
                    return f.getIndex()%100;
                }
            }
            return 400;
        }

    }

    /**
     *@author  hdj
     *@date
     *@description 状态码
     */
    public enum StatusCode {


        OK(20000, "成功"),

        ERROR(20001, "失败"),

        LOGINERROR(20002, "用户名密码错误") ,

        REMOTEERROE(20004, "远程调用失败"),

        TIMEERROE(20005, "token失效");



        private final int value;
        private final String reasonPhrase;

        StatusCode(int value, String reasonPhrase) {
            this.value = value;
            this.reasonPhrase = reasonPhrase;
        }

        public int value(){
            return this.value;
        }

        public  String getReasonPhrase(){
            return this.reasonPhrase;
        }
    }
}
